#include <stdio.h>
#define ALLOCSIZE 10000
static char allocbuf[ALLOCSIZE];
static char *allocp = allocbuf;

char *alloc(int n){
    if (allocbuf + ALLOCSIZE  >= allocp + n){
        allocp += n;
        return allocp - n;
    } else
        return 0;
}

void afree(char *p){
    if (p >= allocbuf && p< allocbuf + ALLOCSIZE)
        allocp = p;
}

void strcpy(char *s, char *t){
    while (*s++ = *t++)
        ;
}

int srtcmp(char *s, char *t){
    for (;  *s == *t ; s++, t++) {
        if (*s == '\0')
            return 0;
        return *s - *t;
    }
}

/**     从右向左，且比算数级别高
 *      下面是入栈出栈
 *      *p++ = val;    val入栈
 *      val = *--p;    出栈给val
 */

static char daytab[2][13]={
    {0,31,28,31,30,31,30,31,31,30,31,30,31},
    {0,31,29,31,30,31,30,31,31,30,31,30,31},
};
int day_of_year(int year, int month, int day){
    int i, leap;
    leap = year%4 && year%100 !=0 || year%400 == 0;
    for (i = 1; i < month; ++i)
        day += daytab[leap][i];
    return day;
}

void month_day(int year, int yearday, int *pmonth, int *pday){
    int i, leap;
    leap = year%4 && year%100 !=0 || year%400 == 0;
    for (i = 1; yearday > daytab[leap][i]; ++i)
        yearday -= daytab[leap][i];
    *pmonth = i;
    *pday = yearday;
}

int main() {

    return 0;
}











